﻿using System;
using System.IO;
using System.Collections;
using System.ComponentModel;
using System.Xml.Serialization;
using UnityEngine;
using Sirenix.OdinInspector;

namespace MainScene.Evt.Condition
{
    /// <summary>
    /// 默认场景的事件 (事件条件)
    /// </summary>
    [Serializable]
    //[XmlInclude(typeof(OnAreaTriggerAwaysConditionData))]
    [XmlInclude(typeof(OnActionConditionData))]
    [XmlInclude(typeof(OnEffectConditionData))]
    [XmlInclude(typeof(OnAreaTriggerConditionData))]
    [XmlInclude(typeof(OnSceneEventConditionData))]
    [XmlInclude(typeof(OnTriggerMsgConditionData))]
    [XmlInclude(typeof(OnUnitDeadConditonData))]
    [XmlInclude(typeof(OnHoldRoleConditionData))]
    [XmlInclude(typeof(OnCatchRoleConditionData))]
    [XmlInclude(typeof(OnGameTriggerEventData))]
    [XmlInclude(typeof(OnUnitClickConditionData))]
    [XmlInclude(typeof(OnAreaTriggerMutliConditionData))]
    [XmlInclude(typeof(OnUnitBeScanningData))]
    [XmlInclude(typeof(OnUnitScanningNumsData))]
    [TypeConverterAttribute(typeof(ExpandableObjectConverter))]
    public abstract class ConditionData
    {     
        [XmlIgnore]
        public EvtConditionType conditionType { get; protected set; }
    }

    /// <summary>
    /// 播放指定角色动画事件
    /// </summary>
    [Serializable]
    public class OnActionConditionData : ConditionData
    {
        [XmlAttribute("unitName")]
        public string unitName;
        [XmlAttribute("actionId")]
        public string actionId;

        public OnActionConditionData()
        {
            conditionType = EvtConditionType.OnAction;
            unitName = string.Empty;
            actionId = string.Empty;
        }
    }

    /// <summary>
    /// 播放指定特效事件
    /// </summary>
    [Serializable]
    public class OnEffectConditionData : ConditionData
    {
        [XmlAttribute("effectId")]
        public string effectId;

        public OnEffectConditionData()
        {
            conditionType = EvtConditionType.OnEffect;
            effectId = string.Empty;
        }
    }
    //[Serializable]
    //public class OnAreaTriggerAwaysConditionData : ConditionData
    //{
    //    [XmlAttribute("areaId")]
    //    public string areaId;
    //    [XmlAttribute("unitName")]
    //    public string unitName;
    //    [XmlAttribute("eventType")]
    //    public TriggerMsgId eventType;

    //    public OnAreaTriggerAwaysConditionData()
    //    {
    //        conditionType = EvtConditionType.OnAwaysArea;
    //        areaId = string.Empty;
    //        unitName = string.Empty;
    //        eventType = TriggerMsgId.Enter;
    //    }
    //}
    /// <summary>
    /// 场景区域触发事件
    ///  四个行为
    ///  Active,
    ///  Destroy,
    ///  Enter,
    ///  Stay,
    ///  Exit,
    /// </summary>
    [Serializable]
    public class OnAreaTriggerConditionData : ConditionData
    {
        [XmlAttribute("areaId")]
        public string areaId;
        [XmlAttribute("unitName")]
        public string unitName;
        [XmlAttribute("eventType")]
        public TriggerMsgId eventType;

        public OnAreaTriggerConditionData()
        {
            conditionType = EvtConditionType.OnArea;
            areaId = string.Empty;
            unitName = string.Empty;
            eventType = TriggerMsgId.Stay;
        }
    }


    [Serializable]
    public class OnAreaTriggerMutliConditionData : ConditionData
    {
        [XmlAttribute("areaId")]
        public string areaId;
        public System.Collections.Generic.List<string> unitName;
        //[XmlAttribute("eventType")]
        //public TriggerMsgId eventType;

        public OnAreaTriggerMutliConditionData()
        {
            conditionType = EvtConditionType.OnAreaMutil;
            areaId = string.Empty;
            unitName = new System.Collections.Generic.List<string>();
            //eventType = TriggerMsgId.Stay;
        }
    }


    /// <summary>
    /// 场景的事件类型
    /// eventId 用户自定义的场景事件的 完成的触发
    /// </summary>
    [Serializable]
    public class OnSceneEventConditionData : ConditionData
    {
        [XmlAttribute("eventId")]
        public string eventId;

        public OnSceneEventConditionData()
        {
            conditionType = EvtConditionType.OnSceneEvt;
            eventId = string.Empty;
        }
    }

  

    /// <summary>
    /// 具体触发器的事件
    /// </summary>
    [Serializable]
    public class OnTriggerMsgConditionData : ConditionData
    {
        [XmlAttribute("triggerName")]
        public string triggerName;
        [XmlAttribute("triggerEvent")]
        public TriggerMsgId triggerEvent;

        public OnTriggerMsgConditionData()
        {
            conditionType = EvtConditionType.OnTriggerEvt;
            triggerName = string.Empty;
            triggerEvent = TriggerMsgId.Active;
        }
    }
    [Serializable]
    public class OnUnitScanningNumsData : ConditionData
    {
        [XmlAttribute("targetObjectId")]
        public string targetObjectId;
        [XmlAttribute("beScanningNums")]
        public int beScanningNums;
        public OnUnitScanningNumsData()
        {
            conditionType = EvtConditionType.OnScanningNum;
            targetObjectId = string.Empty;
        }
    }
    [Serializable]
    public class OnUnitBeScanningData : ConditionData
    {
        [XmlAttribute("scanningObjectId")]
        public string scanningObjectId;
        [XmlAttribute("beScanningObjectId")]
        public string beScanningObjectId;
        public OnUnitBeScanningData()
        {
            conditionType = EvtConditionType.OnBeScanning;
            scanningObjectId = string.Empty;
            beScanningObjectId = string.Empty;
        }
    }

    /// <summary>
    /// 指定怪死亡事件
    /// </summary>
    [Serializable]
    public class OnUnitDeadConditonData : ConditionData
    {
        [XmlAttribute("deadUnitObjectId")]
        public string deadUnitObjectId;
        public OnUnitDeadConditonData()
        {
            conditionType = EvtConditionType.OnUnitDead;
            deadUnitObjectId = string.Empty;
        }
    }

    [Serializable]
    public class OnUnitClickConditionData : ConditionData
    {
        [XmlAttribute("unitName")]
        public string unitName;
        public OnUnitClickConditionData()
        {
            conditionType = EvtConditionType.OnUnitClick;
            unitName = string.Empty;
        }
    }

    /// <summary>
    /// 指定怪发现主角事件
    /// </summary>
    [Serializable]
    public class OnHoldRoleConditionData : ConditionData
    {
        [XmlAttribute("objectId")]
        public string objectId;
        public OnHoldRoleConditionData()
        {
            conditionType = EvtConditionType.OnHoldRole;
            objectId = string.Empty;
        }
    }

    /// <summary>
	/// 指定怪撞到主角事件
	/// </summary>
	[Serializable]
    public class OnCatchRoleConditionData : ConditionData
    {
        [XmlAttribute("objectId")]
        public string objectId;
        public OnCatchRoleConditionData()
        {
            conditionType = EvtConditionType.OnCatchRole;
            objectId = string.Empty;
        }
    }

    /// <summary>
    /// 游戏逻辑触发事件
    /// </summary>
    [Serializable]
    public class OnGameTriggerEventData : ConditionData
    {
        [XmlAttribute("storyId")]
        public string storyId;

        public OnGameTriggerEventData()
        {
            conditionType = EvtConditionType.OnGameTrigger;
            storyId = string.Empty;
        }
    }
}
